using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.SqlClient;

namespace SapaFinance.Domain.EntityFramework
{
    public class DbModelConfigure
    {
        private readonly DbModelBuilder _modelBuilder;

        public DbModelConfigure(string connectionString)
        {
            _modelBuilder = new DbModelBuilder();
            _modelBuilder.Configurations.Add(new BudgetItemConfiguration());
            _modelBuilder.Configurations.Add(new CurrencyConfiguration());
            _modelBuilder.Configurations.Add(new BankConfiguration());
            _modelBuilder.Configurations.Add(new OrderConfiguration());
            _modelBuilder.Configurations.Add(new UserConfiguration());
            _modelBuilder.Configurations.Add(new PaymentTypeConfiguration());
            _modelBuilder.Configurations.Add(new RequestConfiguration());
            _modelBuilder.Configurations.Add(new IdentityConfiguration());
            _modelBuilder.Configurations.Add(new TaxRateConfiguration());
            _modelBuilder.Configurations.Add(new MoneyConfiguration());
            _modelBuilder.Configurations.Add(new AgentConfiguration());
            _modelBuilder.Configurations.Add(new CorporationConfiguration());
            _modelBuilder.Configurations.Add(new AccountConfiguration());
            _modelBuilder.Configurations.Add(new CFOConfiguration());
            _modelBuilder.Configurations.Add(new ShareConfiguration());
            Model = _modelBuilder.Build(new SqlConnection(connectionString));
            CompiledModel = Model.Compile();
        }

        public DbModel Model { get; private set; }
        public DbCompiledModel CompiledModel { get; private set; }
    }
}